package com.ruoyi.web.controller.dr;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dr.domain.DrHomeSell;
import com.ruoyi.dr.service.IDrHomeSellService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 达人主页销售信息Controller
 * 
 * @author ruoyi
 * @date 2025-07-12
 */
@RestController
@RequestMapping("/dr/sell")
public class DrHomeSellController extends BaseController
{
    @Autowired
    private IDrHomeSellService drHomeSellService;

    /**
     * 查询达人主页销售信息列表
     */
    @PreAuthorize("@ss.hasPermi('dr:sell:list')")
    @GetMapping("/list")
    public TableDataInfo list(DrHomeSell drHomeSell)
    {
        startPage();
        List<DrHomeSell> list = drHomeSellService.selectDrHomeSellList(drHomeSell);
        return getDataTable(list);
    }

    /**
     * 导出达人主页销售信息列表
     */
    @PreAuthorize("@ss.hasPermi('dr:sell:export')")
    @Log(title = "达人主页销售信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DrHomeSell drHomeSell)
    {
        List<DrHomeSell> list = drHomeSellService.selectDrHomeSellList(drHomeSell);
        ExcelUtil<DrHomeSell> util = new ExcelUtil<DrHomeSell>(DrHomeSell.class);
        util.exportExcel(response, list, "达人主页销售信息数据");
    }

    /**
     * 获取达人主页销售信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('dr:sell:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(drHomeSellService.selectDrHomeSellById(id));
    }

    /**
     * 新增达人主页销售信息
     */
    @PreAuthorize("@ss.hasPermi('dr:sell:add')")
    @Log(title = "达人主页销售信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DrHomeSell drHomeSell)
    {
        return toAjax(drHomeSellService.insertDrHomeSell(drHomeSell));
    }

    /**
     * 修改达人主页销售信息
     */
    @PreAuthorize("@ss.hasPermi('dr:sell:edit')")
    @Log(title = "达人主页销售信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DrHomeSell drHomeSell)
    {
        return toAjax(drHomeSellService.updateDrHomeSell(drHomeSell));
    }

    /**
     * 删除达人主页销售信息
     */
    @PreAuthorize("@ss.hasPermi('dr:sell:remove')")
    @Log(title = "达人主页销售信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(drHomeSellService.deleteDrHomeSellByIds(ids));
    }
}
